<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>芝士erp退货管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/resources/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/resources/css/public.css" media="all"/>

</head>
<body class="childrenBody">
<!-- 查询条件开始 -->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 5px;">
    <legend>查询条件</legend>
</fieldset>
<blockquote class="layui-elem-quote">
    <form action="" method="post" id="searchForm" lay-filter="searchForm" class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">客户名称</label>
                <div class="layui-input-inline">
                    <select name="customerid" id="search_customerid" lay-filter="search_customerid">
                        <option value=" 0">请选择客户名称</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">商品名称</label>
                <div class="layui-input-inline">
                    <select name="goodsid" id="search_goodsid">
                        <option value="0">请选择商品名称</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">操作员</label>
                <div class="layui-input-inline">
                    <input type="text" name="operateperson" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="startDate" readonly="readonly" id="startDate" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="endDate" readonly="readonly" id="endDate" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-inline">
                    <input type="text" name="remark" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" style="text-align: right;">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="doSearch"><span
                        class="layui-icon layui-icon-search"></span>查询
                </button>
                <button type="reset" class="layui-btn layui-btn-warm"
                        onclick="javascript:document.getElementById('search_customerid').value=null"><span
                        class="layui-icon layui-icon-refresh-1"></span>重置
                </button>
            </div>
        </div>
    </form>
</blockquote>
<!-- 查询条件结束-->


<!-- 数据表格开始 -->
<div>
    <table class="layui-hide" id="salesbackTable" lay-filter="salesbackTable"></table>
</div>

<!-- 数据表格结束 -->

<script type="text/javascript" src="/resources/layui/layui.js"></script>
<script type="text/javascript" th:inline="none">
    var tableIns;
    layui.use(['jquery', 'form', 'table', 'layer', 'laydate'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var table = layui.table;
        var layer = layui.layer;
        var laydate = layui.laydate;
        //渲染时间选择器
        laydate.render({
            elem: '#startDate',
            type: 'datetime'
        });
        laydate.render({
            elem: '#endDate',
            type: 'datetime'
        });

        //加载 数据
        tableIns = table.render({
            elem: '#salesbackTable'
            , url: '/salesback/loadAllSalesback'
            , toolbar: true //开启头部工具栏，并为其绑定左侧模板
            , title: '商品退货数据表'
            , height: 'full-283'
            , page: true
            , cols: [[
                {field: 'id', title: '退货ID', align: 'center'},
                {field: 'customername', title: '客户名称', align: 'center'}
                , {field: 'goodsname', title: '商品名称', align: 'center'}
                , {field: 'size', title: '商品规格', align: 'center'}
                , {field: 'salesbacktime', title: '退货时间', align: 'center'}
                , {field: 'number', title: '退货数量', align: 'center'}
                , {field: 'salebackprice', title: '退货价格', align: 'center'}
                , {field: 'remark', title: '备注', align: 'center'}
                , {field: 'operateperson', title: '操作员', align: 'center'}
            ]]
        });

        //加载查询条件供应商的下拉列表
        $.get("/sales/loadAllCustomerForSelect", function (res) {
            var data = res.data;
            var dom = $("#search_customerid");
            var html = '<option value="0">请选择供应商</option>'
            $.each(data, function (index, item) {
                html += '<option value="' + item.id + '" id="">' + item.customername + '</option>'
            })
            dom.html(html);
            form.render("select");
        })
        $.get("/sales/loadGoodsByCustomerId", function (res) {
            var data = res.data;
            var dom = $("#search_goodsid");
            var html = '<option value="0">请选择商品名称</option>'
            $.each(data, function (index, item) {
                html += '<option value="' + item.id + '">' + item.goodsname + '——' + item.size + '</option>'
            })
            dom.html(html);
            form.render("select");
        })

        //模糊查询
        form.on("submit(doSearch)", function (data) {
            tableIns.reload({
                where: data.field,
                page: {
                    curr: 1
                }
            });
            return false;
        });
    });
</script>

</body>
</html>
